// eslint-disable-next-line import/no-extraneous-dependencies
import moment from 'moment';

export const getTimeState = () => {
  // 获取当前时间
  const timeNow = new Date();
  // 获取当前小时
  const hours = timeNow.getHours();
  // 设置默认文字
  let text = ``;
  // 判断当前时间段
  if (hours >= 0 && hours <= 10) {
    text = `早上好`;
  } else if (hours > 10 && hours <= 14) {
    text = `中午好`;
  } else if (hours > 14 && hours <= 18) {
    text = `下午好`;
  } else if (hours > 18 && hours <= 24) {
    text = `晚上好`;
  }
  return text;
};

export const randomDate = (startDate: any, endDate: any) => {
  const date = new Date(+startDate + Math.random() * (endDate - startDate));
  const hour = 0 + Math.random() * (23 - 0);
  const minute = 0 + Math.random() * (59 - 0);
  const second = 0 + Math.random() * (59 - 0);
  date.setHours(hour);
  date.setMinutes(minute);
  date.setSeconds(second);
  return date;
};


// 截止日期
const endDate = new Date();

export const randomTime = () => moment(randomDate(moment().startOf('month').toDate(), endDate)).format('YYYY-MM-DD HH:mm'); // '2019-08-14 21:19:36'
